<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ZyAdmin-我</title>
    <link th:replace="template/mobile_template :: header"/>
</head>
<body style="background: #eee;">
<div class="weui-tab">
    <div class="container" style="margin-bottom: 50px;">
        <div class="my_top">
            <div class="my_top_head"><img src="/images/head.jpg"></div>
            <div>
                <span class="my_top_title" id="userName">刘德华</span>
                <span class="my_top_remark">WeUI由微信官方设计团队为微信内网页和微信小程序量身设计，令用户的使用感知更加统一</span>
            </div>
            <!--<div class="weui-avatar-circle">
                <img src="/images/head.jpg">
                <span class="weui-icon-success weui-icon-safe-warn"></span>
            </div>-->
        </div>
        <ul class="my_list_ui">
            <li><a href="#"><span class="float_lf">我的信息</span> <i class="float_rt icon icon-108"></i><span class="float_rt">查看更多</span></a></li>
        </ul>

        <ul class="my_gridbox_ui">
            <li><a href="#"><i class="icon icon-1 fontsize28"></i><span>待付款</span></a></li>
            <li><a href="#"><i class="icon icon-2 fontsize28"></i><span>待确认</span></a></li>
            <li><a href="#"><i class="icon icon-11 fontsize28"></i><span>待出团</span></a></li>
            <li><a href="#"><i class="icon icon-14 fontsize28"></i><span>待评价</span></a></li>
        </ul>

        <ul class="my_list_ui">
            <li><a href="#"><i class="float_lf icon icon-5"></i><span class="float_lf">我的收藏</span> </a></li>
            <li><a href="#"><i class="float_lf icon icon-48"></i><span class="float_lf">我的咖友</span> </a></li>
            <li><a href="#"><i class="float_lf icon icon-54"></i><span class="float_lf">我的福利</span> </a></li>
            <li><a href="#"><i class="float_lf icon icon-67"></i><span class="float_lf">我的消息</span> </a></li>
            <li><a href="#"><i class="float_lf icon icon-102"></i><span class="float_lf">账户设置</span> </a></li>
            <li onclick="loginOut()"><a href="#"><i class="float_lf icon icon-72"></i><span class="float_lf">退出系统</span> </a></li>
        </ul>

        <!-- 底部公司简介 -->
        <div th:replace="template/mobile_template :: footer_company"></div>
    </div>
    <!-- 底部菜单 -->
    <div th:replace="template/mobile_template :: footer_menu"></div>
</div>

<script type="text/javascript" th:replace="template/mobile_template :: footer"></script>
<script type="text/javascript" th:inline="javascript">
    $(function () {
        $("#footer_menu a").eq(3).addClass("weui-bar__item_on").siblings().removeClass("weui-bar__item_on");
        //判断是否登录，未登录要先登录，然后查询个人信息

        var token = getCookie("token");
        if(token && token != ""){
            //查询数据
            var userInfo = wxGetUserInfo();
            console.log(userInfo);
            if(userInfo){
                $("#userName").text(userInfo.userName);
            }
        }else {
            wxlogin(function () {
                loadUserInfo();
            });
        }
    });

    //加载用户数据
    function loadUserInfo() {
        //console.log("loadData...");
        //发起请求
        new AjaxRequest({
            type: "GET",
            url: webroot + "sys/user",
            isShowLoader: false,
            success: function (res) {
                //console.log(res);
                if (res) {
                    if (res.resultCode == "0000" && res.resultObj != "") {
                        var userInfo = res.resultObj;
                        $.showLoading(userInfo.userName + " 欢迎回来")
                        //存储到localStorage中
                        $("#userName").text(userInfo.userName);
                        wxSetUserInfo(userInfo);
                        setTimeout(function() {
                            $.hideLoading();
                        }, 1000)
                    } else {
                        $.toast(res.resultMessage, "cancel");
                    }
                }
            },
            error: function (err) {
                $.hideLoading();
            }
        });
    }

    //退出登录
    function loginOut() {
        $.confirm("您确定要退出系统吗?", "确认退出?", function() {
            delCookie("token");
            window.location.href = '/wx/index';
        }, function() {
            //取消操作
        });
    }
</script>
</body>
</html>